package com.czxy.demo12;

public class Test01 {

    public static void main(String[] args) {


        String[][] all = {
                {"张三", "37", "89", "5"},
                {"李四", "95", "41", "79"},
                {"王五", "60", "84", "29"},
                {"赵六", "87", "46", "86"}
        };
        printMathScore(all);
        getCountMathScore(all);
        getAvgMathScore(all);
        getAvgName(all);
        getAvgCount(all);
    }

    public static void printMathScore(String[][] arr) {
        for (String[] s : arr) {
            System.out.println(s[2]);
        }
    }

    public static void getCountMathScore(String[][] arr) {
        int sum = 0;
        for (String[] s : arr) {
            sum += Integer.parseInt(s[2]);
        }
        System.out.println("所有同学数学成绩的总和" + sum);
    }

    public static void getAvgMathScore(String[][] arr) {
        int sum = 0;
        for (String[] s : arr) {
            sum += Integer.parseInt(s[2]);
        }
        System.out.println("所有同学数学成绩的平均分" + sum / arr.length);
    }

    public static void getAvgName(String[][] arr) {
        int sum = 0;
        for (String[] s : arr) {
            sum += Integer.parseInt(s[2]);
        }
        int avg = sum / arr.length;
        System.out.println("数学成绩超过平均分的人名");
        for (int i = 0; i < arr.length; i++) {
            if (Integer.parseInt(arr[i][2]) > avg){
                System.out.println(arr[i][0]);
            }
        }
    }
    public static void  getAvgCount(String[][]arr){
        int sum = 0;
        for (String[] s : arr) {
            sum += Integer.parseInt(s[2]);
        }
        int count=0;
        int avg=sum/arr.length;
        for (int i = 0; i < arr.length; i++) {
            if (Integer.parseInt(arr[i][2])>avg){
                count++;
            }
        }
        System.out.println("数学成绩高过平均分的人数"+count);
    }

}
